]> git.r.bdr.sh - rbdr/super-polarity/blob - Super Polarity/Actors/Bullet.cs
I think bullets come out now.
[rbdr/super-polarity] / Super Polarity / Actors / Bullet.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Graphics;
7
8 namespace SuperPolarity
9 {
10 class Bullet : Actor
11 {
12 protected ParticleEngine particleEngine;
13
14 public Bullet(Game newGame)
15 : base(newGame)
16 {
17 }
18
19 ~Bullet()
20 {
21 particleEngine = null;
22 }
23
24 public override void Initialize(Texture2D texture, Vector2 position)
25 {
26 base.Initialize(texture, position);
27 particleEngine = ParticleEffectFactory.CreateBullet(position);
28 }
29
30 public override void Update(GameTime gameTime)
31 {
32 Velocity.X = (float)(MaxVelocity * Math.Cos(Angle));
33 Velocity.Y = (float)(MaxVelocity * Math.Sin(Angle));
34
35 Position += Velocity;
36
37 particleEngine.Update();
38 particleEngine.EmitterLocation = Position;
39 }
40
41 public override void Draw(SpriteBatch spriteBatch)
42 {
43 base.Draw(spriteBatch);
44 particleEngine.Draw(spriteBatch);
45 }
46 }
47 }